/*
* Copyright (c) 2007, Stanisław Pitucha
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Stanisław Pitucha ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Stanisław Pitucha BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

using System;
using System.Net;
using System.IO;
using System.Xml;
using System.Text;

namespace VeohDownloaderSharp
{
	
	
	public class VeohRequest
	{
		private string _url;
		private string _data;
		
		public VeohRequest()
		{
		}
		
		public XmlDocument RequestXml() {
			HttpWebRequest req = (HttpWebRequest) WebRequest.Create(_url);
			req.Method = "POST";
			req.UserAgent = "veoh-3.2.0 service (NT 5.1; IE 6.0.2900.2180; en-US Windows; LOL! Linux really ;) )";
			req.ContentType = "application/xml";
			
			byte[] postData = Encoding.ASCII.GetBytes(_data);
			using(Stream postStream = req.GetRequestStream()) {
				postStream.Write(postData, 0, postData.Length);
			}
			
			using(HttpWebResponse resp = (HttpWebResponse) req.GetResponse()) {
				XmlDocument xd = new XmlDocument();
				xd.Load(resp.GetResponseStream());
				return xd;
			}
		}
		
		public string Url {
			get {
				return _url;
			}
			set {
				_url = value;
			}
		}
		
		public string Data {
			get {
				return _data;
			}
			set {
				_data = value;
			}
		}
	}
}
